#define _CRT_SECURE_NO_WARNINGS
class Foo {
public:
    Foo() {

    }
    std::mutex mut;
    std::condition_variable cv;
    int i = 0;
    void first(function<void()> printFirst) {

        // printFirst() outputs "first". Do not change or remove this line.
        std::unique_lock<std::mutex> mu(mut);

        printFirst();
        i = 1;
        cv.notify_all();
    }

    void second(function<void()> printSecond) {

        // printSecond() outputs "second". Do not change or remove this line.
        std::unique_lock<std::mutex> mu(mut);
        cv.wait(mu, [this]() {return i == 1; });
        printSecond();
        i = 2;
        cv.notify_one();

    }

    void third(function<void()> printThird) {

        // printThird() outputs "third". Do not change or remove this line.
        std::unique_lock<std::mutex> mu(mut);

        cv.wait(mu, [this]() {return i == 2; });
        printThird();

    }

};